﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using ZK.Common;
using ZK.Models;

namespace ZK.InterfaceServer
{
    public class LSwzzyybfServer
    {



        public static string yxfwIp = "192.168.1.188";
        public static string yxfwPort = "17808";
        public static string wjyyPort = "10008";
        //public static string url = "http://" + yxfwIp + ":" + yxfwPort + "/call";


        public static Models.LSwzzyybfM.loginRes login(Models.LSwzzyybfM.loginReq m)
        {
            string ret;
            try
            {
                Common.ShowBlackBox.WriteLine("1 url：" + "http://" + yxfwIp + ":" + yxfwPort + "/call");
                ret = HttpClientUtil.doPostMethodToString("http://" + yxfwIp + ":" + yxfwPort + "/call", Newtonsoft.Json.JsonConvert.SerializeObject(m));
            }
            catch (Exception ex)
            {
                Common.Log4.LogManage.WriteErr("login " + ex.ToString());
                return null;
            }
            return Newtonsoft.Json.JsonConvert.DeserializeObject<LSwzzyybfM.loginRes>(ret);

        }
        public static Models.LSwzzyybfM.getAllDevicesRes getAllDevices(Models.LSwzzyybfM.getAllDevicesReq m)
        {
            string ret;
            try
            {
                ret = HttpClientUtil.doPostMethodToString("http://" + yxfwIp + ":" + yxfwPort + "/call", Newtonsoft.Json.JsonConvert.SerializeObject(m));
            }
            catch (Exception ex)
            {
                Common.Log4.LogManage.WriteErr("getAllDevices " + ex.ToString());
                return null;
            }
            return Newtonsoft.Json.JsonConvert.DeserializeObject<LSwzzyybfM.getAllDevicesRes>(ret);

        }
        public static Models.LSwzzyybfM.playMusicRes playMusic(Models.LSwzzyybfM.playMusicReq m)
        {
            string ret;
            try
            {
                ret = HttpClientUtil.doPostMethodToString("http://" + yxfwIp + ":" + yxfwPort + "/call", Newtonsoft.Json.JsonConvert.SerializeObject(m));
            }
            catch (Exception ex)
            {
                Common.Log4.LogManage.WriteErr("playMusic " + ex.ToString());
                return null;
            }
            return Newtonsoft.Json.JsonConvert.DeserializeObject<LSwzzyybfM.playMusicRes>(ret);

        }

        public static Models.LSwzzyybfM.playMusicRes devPlayStop(Models.LSwzzyybfM.devPlayStopReq m)
        {
            string ret;
            try
            {
                ret = HttpClientUtil.doPostMethodToString("http://" + yxfwIp + ":" + yxfwPort + "/call", Newtonsoft.Json.JsonConvert.SerializeObject(m));
            }
            catch (Exception ex)
            {
                Common.Log4.LogManage.WriteErr("devPlayStop " + ex.ToString());
                return null;
            }
            return Newtonsoft.Json.JsonConvert.DeserializeObject<LSwzzyybfM.playMusicRes>(ret);

        }

        public static Models.LSwzzyybfM.tts_xfRes tts_xf(Models.LSwzzyybfM.tts_xf m)
        {
            string ret;
            Dictionary<string, string> keyValuePairs = new Dictionary<string, string>();
            keyValuePairs.Add("origin", m.origin);
            keyValuePairs.Add("text", m.text);
            keyValuePairs.Add("voice_name", m.voice_name);
            keyValuePairs.Add("volume", m.volume);
            keyValuePairs.Add("speed", m.speed);
            string myUrl = InterfaceExecute.GetUrlNoBaseUrl("http://" + yxfwIp + ":" + wjyyPort + "/tts_xf.multi", keyValuePairs);
            try
            {
                ret = HttpClientUtil.doGetMethodToString(myUrl);
            }
            catch (Exception ex)
            {
                Common.Log4.LogManage.WriteErr("tts_xf " + ex.ToString());
                return null;
            }
            return Newtonsoft.Json.JsonConvert.DeserializeObject<LSwzzyybfM.tts_xfRes>(ret);

        }
    }
}
